package com.seele.tigerwallet.ui.utils;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.seele.tigerwallet.R;

public class LoadWebViewManager {

    private BaseDialog mBaseDialog;
    private Context mContext;

    private WebView mWebView;


    public LoadWebViewManager(Context context) {
        mContext = context;
        initDialog();
    }

    private void initDialog() {

        if (null == mBaseDialog) {
            mBaseDialog = new BaseDialog.Builder(mContext)
                    .view(R.layout.load_web_view)
                    .setWidthPX((int) mContext.getResources().getDimension(R.dimen.dp_68))
                    .cancelTouchout(false)
                    .setHeightPX((int) mContext.getResources().getDimension(R.dimen.dp_68))
                    .setDialogPosition(Gravity.CENTER) //设置dialog显示位置
                    .build();
        }

        mWebView = mBaseDialog.findView(R.id.webview);



        WebSettings settings = mWebView.getSettings();
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);

        mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);//不加上，会显示白边
        mWebView.loadUrl("file:///android_asset/loading.html");
        mBaseDialog.show();


    }


    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.know_tv:
                    if (null != mBaseDialog) {

                        mBaseDialog.cancel();
                    }

                    break;
            }
        }
    };
}
